from socket import *
from time import strftime
import time
ip_port = ("localhost", 51590)
buffer_size = 1024
udp_server = socket(AF_INET, SOCK_DGRAM)
udp_server.bind(ip_port)
while True:
    print("waiting for recv message....")
    data,addr =udp_server.recvfrom(buffer_size)
    print(time.ctime(),"from clent msg is:",data.decode("utf-8"))

    if not data:
        time_fmt = "%Y-%m-d% %X"
    else:
        time_fmt = data.decode('utf-8')
    bank_time = strftime(time_fmt)
    print(bank_time)
    udp_server.sendto(bank_time.encode("utf-8"),addr)
udp_server.close()